trigger sharepo on Purchase_Object__c (after insert, after update) { 
List<Purchase_Object__Share> poShrs  = new List<Purchase_Object__Share>();
Purchase_Object__Share guShr = new Purchase_Object__Share();
   for(Purchase_Object__c po : trigger.new){
   Id poid = po.id;
    List<Purchase_Object__c> setAccId = [Select Account__r.id from Purchase_Object__c where Purchase_Object__c.id =:poid];
       Id accid;
       accid = SetAccId[0].Account__r.id; 
       System.debug('gggid' + accid);
       List<AccountShare> gID = [Select UserOrGroupId,AccountAccessLevel from AccountShare where AccountId = :accid];
       System.debug('gggid' + gID);
      if(setAccid.Size()>0){
         guShr.ParentId = po.Id;
         guShr.UserOrGroupId = gId[0].UserOrGroupId;
         guShr.AccessLevel = 'read';
        poShrs.add(guShr);
     System.debug('gert' + poShrs);
  insert poShrs;                   
  }
 }
}